package lib.wzh.com.libcore.framework.chain;

import lib.wzh.com.libcore.framework.enums.ResponseEnum;
import lib.wzh.com.libcore.framework.response.BaseResponse;

/**
 * @Author lib
 * @Date 2021/12/4 14:01
 * @ClassName ReturnBoolean
 * @Version v1.0
 */

public class ReturnBoolean extends ReturnChain{

    @Override
    public <T> BaseResponse<T> returnHandler(T data) {
        if(data instanceof Boolean){
            Boolean bl = (Boolean) data;
            if(!bl){
                return new BaseResponse<>(ResponseEnum.FAIL.code(), ResponseEnum.FAIL.msg(), ResponseEnum.FAIL.success());
            }else {
                return new BaseResponse<>(ResponseEnum.SUCCESS.code(), ResponseEnum.SUCCESS.msg(), ResponseEnum.SUCCESS.success(),data);
            }
        }else {
            if(null != getChain()){
              return getChain().returnHandler(data);
            }
            return new BaseResponse<>(ResponseEnum.SUCCESS.code(), ResponseEnum.SUCCESS.msg(), ResponseEnum.SUCCESS.success(),data);
        }
    }
}
